//
//  WXUtils.h
//  UtilsDemo
//
//  Created by wulanzhou on 16/10/2.
//  Copyright © 2016年 wulanzhou. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void (^WXPayFininshedBlock) (BOOL success,NSString *errCode,NSString *errMsg);
typedef void (^WXShareFininshedBlock) (BOOL success,NSString *errCode,NSString *errMsg);

/**
 *  微信支付与分享
 *
 *  微信支付信息配置
 *
 *  微信支付分为三步
 *  1.取得访问权限gettoken
 *  2.根据订单生成预支付id
 *  3.通过预支付id调用微信支付
 *  注：1，2步可通过后台来处理，客户端取得预支付id再调起微信支付
 */
@interface WXUtils : NSObject

/**
 *  开发者Id,默认值:wxefffce4487a046fc
 *  注：返回应用url scheme type设置
 */
@property (nonatomic,strong) NSString *appId;

/**
 *  开发者密钥,默认值:ece56b32cc1082d610a5eebb87a2a620
 */
@property (nonatomic,strong) NSString *appAppSecret;

/**
 *  商户Id,默认值:1250121901
 */
@property (nonatomic,strong) NSString *partnerId;

/**
 *  单例
 *
 *  @return
 */
+ (WXUtils *)shareInstance;

/**
 *  注册微信
 */
- (void)regisetWXPay;

/**
 *  判断是否有安装微信
 *
 *  @return
 */
- (BOOL)isisWXAppInstalled;

/**
 *  打开网址,应用调用handleOpenURL时调用
 *
 *  @param url
 *
 *  @return
 */
- (BOOL)handleOpenURL:(NSURL *)url;

/**
 *  微信支付
 *
 *  @param wxAppId             appId
 *  @param wxPartnerId         商户id
 *  @param prepay_id           预支付id
 *  @param nonceStr            随机字符串
 *  @param timestamp           时间戳
 *  @param sign                签名
 *  @param aPayFinishedBlock   支付结果回调
 */
- (void)payWithAppId:(NSString *)wxAppId
           partnerId:(NSString *)wxPartnerId
            perpayId:(NSString *)prepay_id
            nonceStr:(NSString *)nonceStr
           timeStamp:(UInt32)timestamp
                sign:(NSString *)sign
        payCompleted:(WXPayFininshedBlock)aPayFinishedBlock;

/**
 *  微信支付(必须保证 appId，partnerId属性配置值不能有误)
 *
 *  @param prepay_id         预支付id
 *  @param nonceStr          随机字符串
 *  @param timestamp         时间戳
 *  @param sign              签名
 *  @param aPayFinishedBlock 支付结果回调
 */
- (void)payWithPerpayId:(NSString *)prepay_id
               nonceStr:(NSString *)nonceStr
              timeStamp:(UInt32)timestamp
                   sign:(NSString *)sign
           payCompleted:(WXPayFininshedBlock)aPayFinishedBlock;

/**
 *  微信支付 (必须保证 appId，appAppSecret，partnerId属性配置值不能有误)
 *
 *  @param prepay_id         预支付id
 *  @param aPayFinishedBlock 支付结果回调
 */
- (void)payWithPerpayId:(NSString *)prepay_id
           payCompleted:(WXPayFininshedBlock)aPayFinishedBlock;


#pragma mark -分享

/**
 分享给朋友
 
 @param shareTitle          分享标题
 @param shareMsg            分享内容
 @param shareImgData        分享缩图
 @param shareUrl            分享的url
 @param aShareFinishedBlock 分享结果回调
 */
- (void)shareToFriendWithTitle:(NSString *)shareTitle
                       message:(NSString *)shareMsg
                     imageData:(NSData *)shareImgData
                       linkUrl:(NSString *)shareUrl
                shareCompleted:(WXShareFininshedBlock)aShareFinishedBlock;

/**
 分享到朋友圈
 
 @param shareTitle          分享标题
 @param shareMsg            分享内容(内容不会显示)
 @param shareImgData        分享缩图
 @param shareUrl            分享的url
 @param aShareFinishedBlock 分享结果回调
 */
- (void)shareToFriendGroupWithTitle:(NSString *)shareTitle
                            message:(NSString *)shareMsg
                          imageData:(NSData *)shareImgData
                            linkUrl:(NSString *)shareUrl
                     shareCompleted:(WXShareFininshedBlock)aShareFinishedBlock;

@end
